View.vue
<template>
  <h1>表单组件</h1>
  <!-- 所有的控件必须放在"表单项"中 -->
  <el-form style="width:400px; margin:0 auto;" label-width="100px">
    <el-form-item label="用户名">
      <el-input placeholder="请输入用户名" v-model="user.username"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input placeholder="请输入密码" show-password v-model="user.password"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio value="1" label="男"></el-radio>
        <el-radio value="0" label="女"></el-radio>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select v-model="user.city" placeholder="请选择城市">
        <el-option value="beijing" label="北京"></el-option>
        <el-option value="shanghai" label="上海"></el-option>
        <el-option value="guangzhou" label="广州"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.admin"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="submit">点此提交</el-button>
    </el-form-item>

  </el-form>
</template>

<script setup>
  import {ref} from "vue";

  const user = ref({
    username:'',password:'',gender:'',city:'',admin:false
  })
  const userArr = ref([]);
  const submit = ()=>{
    userArr.value.push(user.value);
    console.log(user.value);
    user.value = {username:'',password:'',gender:'',city:'',admin:false};
  }
</script>

<style scoped>

</style>